<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

//-----------------------{static pages }-------------------------//
Route::get('/', 'PagesController@root')->name('root');

//-----------------------{ 组件 }-------------------------//


//-----------------------Auth::routes()-------------------------//
Auth::routes();

Route::any('password/mobile', 'Auth\ForgotPasswordController@sendResetLinkMobile')->name('password.mobile');
Route::post('password/resetCodeSms', 'Auth\ResetPasswordController@resetCodeSms')->name('password.resetCodeSms');
//验证码
Route::get('register/seedRegistrationSms', 'Auth\RegisterController@seedRegistrationSms')->name('seedRegistrationSms');
//-----------------------{ 用户中心 }-------------------------//
Route::resource('users', 'UsersController', ['only' => ['show', 'update', 'edit']]);
Route::prefix('userhome')->group(function () {
    Route::view('/', 'users.home')->name('userhome');
});
Route::resource('notifications', 'NotificationsController', ['only' => ['index']]);


//权限提醒
Route::get('permission-denied', 'PagesController@permissionDenied')->name('permission-denied');
//-----------------------{ 关注 }-------------------------//
Route::get('/users/{user}/followings', 'UsersController@followings')->name('users.followings');
Route::get('/users/{user}/followers', 'UsersController@followers')->name('users.followers');

//关注用户
Route::post('/users/followers/{user}', 'FollowersController@store')->name('followers.store');

//取消关注
Route::delete('/users/followers/{user}', 'FollowersController@destroy')->name('followers.destroy');

//-----------------------{ 课程 模块 }-------------------------//
Route::prefix('lessons')->group(function () {
    Route::view('/', 'lessons.list')->name('lessons');
    Route::view('/details', 'lessons.details')->name('lessons.details');
    Route::view('/video', 'lessons.video')->name('lessons.video');
});

//-----------------------{ 达人问答 模块 }-------------------------//
Route::prefix('talents')->group(function () {
    Route::view('/', 'talents.list')->name('talents');
});

//-----------------------{ 线上训练班 模块 }-------------------------//
Route::prefix('courses')->group(function () {
    Route::view('/', 'courses.list')->name('courses');
});

//-----------------------{ 论坛 模块 }-------------------------//
Route::prefix('forum')->group(function () {
    Route::view('/', 'forum.list')->name('forum');
    Route::view('/post', 'forum.post')->name('forum.post');
    Route::resource('/topics', 'ForumTopicsController',  ['only' => ['index', 'create', 'store', 'update', 'edit', 'destroy']]);
    Route::resource('/categories', 'CategoriesController', ['only' => ['show']]);
    //发帖上传图片
    Route::post('upload_image', 'ForumTopicsController@uploadImage')->name('topics.upload_image');
    Route::get('topics/{topic}/{slug?}', 'ForumTopicsController@show')->name('topics.show');
    Route::resource('replies', 'RepliesController', ['only' => ['store', 'destroy']]);
});
